package Text_63;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Code {

	public static void main(String[] args) {
		 String str = "aabbcabcadde";
	        TreeMap<Character,Integer> tm = new TreeMap<>();
	        for (int i = 0; i < str.length(); i++) {
	            char c = str.charAt(i);
	            if(tm.containsKey(c)){
	                int count = tm.get(c);
	                count++;
	                tm.put(c,count);
	            }else{
	                tm.put(c,1);
	            }
	        }
	        System.out.println(tm);
	        StringBuilder s = new StringBuilder();
	        Set<Map.Entry<Character, Integer>> entries = tm.entrySet();
	        for (Map.Entry<Character, Integer> entry : entries){
	            char key = entry.getKey();
	            int value = entry.getValue();
	            s.append(key+"("+value+")"+" ");
	        }
	        System.out.println(s);

	}

}
